<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <style type="text/css">
        *{
            margin: 0px;
            padding: 0px;
        }

        html, body {
            width: 100%;
            height: 100%;
            overflow-x: hidden;
          
        }

        footer ul {
            display: flex;
            position:fixed;
            left: 0px;
            bottom: 0px;
            width: 100%;
            height:40px;
        }

        footer ul li {
            flex: 1;
            text-align: center;
            list-style: none;
            height: 40px;
            background: gray
        }

        .kerwin-enter-active {
            animation: aaa 1.5s;
        }

        /* 离开激活 */
        .kerwin-leave-active {
            animation: aaa 1.5s reverse;  /* 逆向渲染 */
        }

        @keyframes aaa {
            0% { 
                opacity: 0;
                transform: translateX(100px);
            }
            100% { 
                opacityopacity: 1; 
                transform:translateX(0px);
            
            }

        }
        
    </style>
</head>
<body>
    <div id="box">
       <keep-alive>

        <transition name="kerwin" mode="out-in">
            <!-- 使用component动态绑定一个变量接收数据 -->
             <component :is="isWhich"></component>
        </transition>

        </keep-alive>
        <footer>
            <ul>
                <li @click=" isWhich='home' ">
                    首页
                </li>

                <li @click=" isWhich='list' ">
                    列表
                </li>

                <li @click=" isWhich='shopcar' ">
                    购物车
                </li>
            </ul>
        </footer>
    </div>
   
    <script type="text/javascript">
        // 首页组件
        Vue.component("home", {
            template:`
            <div>
                home
                <input type="text">
            </div>
            `
        })

        // 列表组件
        Vue.component("list", {
            template:`
            <div>
              list
            </div>
            `
        })

        // 购物车组件
        Vue.component("shopcar", {
            template:`
            <div>
                shopcar
            </div>
            `
        })

        var vm = new Vue ({
            el:"#box",
            data: {
                isWhich:"home"
            }
        })

    </script>
</body>

</html>